<html lang="zh_CN">
{% include "common/tree_page_head.html" %}
<script type="text/javascript"
        src="{{ url_for('static',filename='system/OPM/organization.js',v='1.20220517.1') }}"></script>
<body onload="pageLoad()">
<div class="layui-fluid" style="background: #dddddd; padding: 20px;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md2">
            <div class="layui-card">
                <div class="layui-card-header">机构树</div>
                <div class="layui-card-body" style="height: 89%; padding: 1px;">
                    <form id="main_org_trr" style="display: none;"></form>
                    <div style="width:100%; height:100%; overflow: hidden;">
                        <ul id="JtreeView" class="ztree"></ul>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md10">
            <div class="layui-card">
                <div class="layui-card-header">机构列表</div>
                <div class="layui-card-body" style="height: 89%; padding: 1px;" id="list_view">
                    <table class="layui-hide" id="orglist" lay-filter="orglist"></table>
                    <script type="text/html" id="list_toolbar">
                        <div class="layui-btn-container" style="padding-top: 1px;">
                            <div style='float:left; height: 30px;'>
                                <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="addData"
                                        id="addOrgItem"><span
                                        class='glyphicon glyphicon-plus'></span>&nbsp;新增
                                </button>
                                <button class="layui-btn layui-btn-sm" lay-event="refreshData"><span
                                        class='glyphicon glyphicon-repeat'></span>&nbsp;刷新
                                </button>
                                <button class="layui-btn layui-btn-sm layui-btn-primary" lay-event="sortData">↑↓&nbsp;排序
                                </button>
                            </div>
                            <div class='input-group input-group-sm' style='float:left; width:280px; height: 30px;'>
                                <input type="text" id="query_text" placeholder="快速查询..." class='form-control'>
                                <span class='input-group-btn'>
                                    <button class='btn btn-default' lay-event="quickQuery"><span
                                            class='glyphicon glyphicon-search'></span>查询</button>
                                </span>
                            </div>
                        </div>
                    </script>
                    <script type="text/html" id="actionBar">
                        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="resetPass">重置密码</a>
                        <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="cancelPar">取消分配</a>
                        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="setMainOrg">设置所属部门</a>
                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="move">移动</a>
                        <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="disable">禁用/启用</a>
                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="showdivt" style="display: none;">
    <ul>
        <li>
            <button class="buttnew" id="ogn" onclick="newognData('ogn')" title="新建组织">
                <img src="{{ url_for('static',filename='common/image/toolbar/org/newOgn.gif') }}"
                     style="margin-top: 1px;"/>
                新建组织
            </button>
        </li>
        <li>
            <button class="buttnew" id="dpt" onclick="newognData('dpt')" title="新建部门" disabled>
                <img src="{{ url_for('static',filename='common/image/toolbar/org/newDpt.gif') }}"
                     style="margin-top: 1px;"/>
                新建部门
            </button>
        </li>
        <li>
            <button class="buttnew" id="pos" onclick="newognData('pos')" title="新建岗位" disabled>
                <img src="{{ url_for('static',filename='common/image/toolbar/org/newPos.gif') }}"
                     style="margin-top: 1px;"/>
                新建岗位
            </button>
        </li>
        <li>
            <button class="buttnew" id="psm" onclick="newPsmData()" title="新建人员" disabled>
                <img src="{{ url_for('static',filename='common/image/toolbar/org/newPerson.gif') }}"
                     style="margin-top: 1px;"/>
                新建人员
            </button>
        </li>
        <li>
            <button class="buttnew" id="assignPerson" onclick="assignPsmData()" title="分配人员" disabled>
                <img src="{{ url_for('static',filename='common/image/toolbar/org/newPerson.gif') }}"
                     style="margin-top: 1px;"/>
                分配人员
            </button>
        </li>
    </ul>
</div>
</body>
<script type="text/javascript">
    let currentRow = {};
    layui.use('table', function () {
        var table = layui.table;

        //头工具栏事件
        table.on('toolbar(orglist)', function (obj) {
            switch (obj.event) {
                case 'addData':
                    addorgitem();
                    break;
                case 'refreshData':
                    loadList();
                    break;
                case 'sortData':
                    sortOrgAction();
                    break;
                case 'quickQuery':
                    loadList();
                    break;
            }
        });

        //触发行单击事件
        table.on('row(orglist)', function (obj) {
            //console.log(obj.tr) //得到当前行元素对象
            //console.log(obj.data) //得到当前行数据
            obj.tr.parent().find('tr').removeClass('active')
            obj.tr.addClass('active') //选中行加特殊背景颜色
            currentRow = obj.data;
        });

        //监听行工具事件
        table.on('tool(orglist)', function (obj) {
            //console.log(obj)
            var data = obj.data;
            if (obj.event === 'edit') {
                editOrgData(data);
            }
            if (obj.event === 'resetPass') {
                resetPassword(data);
            }
            if (obj.event === 'cancelPar') {
                disassignPsmFn(data);
            }
            if (obj.event === 'setMainOrg') {
                setMemberOrg(data);
            }
            if (obj.event === 'move') {
                moveOrg(data);
            }
            if (obj.event === 'disable') {
                changeOrgAble(data);
            }
            if (obj.event === 'del') {
                deleteorgitem(data);
            }
        });

    });
</script>
</html>